// 主Ability文件
import { UIAbility } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import Logger from './utils/Logger';

export default class MainAbility extends UIAbility {
  onCreate(want, launchParam) {
    Logger.info('MainAbility', 'Ability onCreate');
  }

  onDestroy() {
    Logger.info('MainAbility', 'Ability onDestroy');
  }

  onWindowStageCreate(windowStage) {
    Logger.info('MainAbility', 'Ability onWindowStageCreate');
    // 设置主页面
    windowStage.loadContent('pages/MainPage', (err, data) => {
      if (err.code) {
        Logger.error('MainAbility', 'Failed to load content: ' + JSON.stringify(err));
        return;
      }
      Logger.info('MainAbility', 'Succeeded in loading content.');
    });
  }

  onWindowStageDestroy() {
    Logger.info('MainAbility', 'Ability onWindowStageDestroy');
  }

  onForeground() {
    Logger.info('MainAbility', 'Ability onForeground');
  }

  onBackground() {
    Logger.info('MainAbility', 'Ability onBackground');
  }
}